package cn.edu.cn.tomatoclock;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Timer;
import java.util.TimerTask;

import cn.edu.cn.tomatoclock.db.RecordManager;

public class TomatoClockFiveMinutesActivity extends AppCompatActivity {
    private static final long POTATO_TIME = 60 * 1000 * 25;
    private static final long PUNISHMENT_TIME = 16 * 1000;
    private TimeDownCount timeDownCount;
    private TextView myTextview;
    RecordManager recordManager;
    private Handler handler;
    private final Timer timer = new Timer();
    private TimerTask task;
    @Override
    protected void onCreate(Bundle TomatoClock) {
        super.onCreate(TomatoClock);
        setContentView(R.layout.five_minutes);
        TextView show = (TextView) findViewById(R.id.tomatoView);
        Intent get = getIntent();
        final int minute = get.getIntExtra("minute", 5);
        timeDownCount = new TimeDownCount(minute * 1000 * 60, 1000) {
            @Override
            public void onFinish() {
                final AlertDialog.Builder builder1 = new AlertDialog.Builder(TomatoClockFiveMinutesActivity.this);
                builder1.setTitle("提示").setMessage("休息結束!");
                builder1.setPositiveButton("專注", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent intent = new Intent(TomatoClockFiveMinutesActivity.this, TomatoClockActivity.class);
                        startActivity(intent);
                    }
                });//有改的部分
                builder1.setNegativeButton("返回", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent intent = new Intent(TomatoClockFiveMinutesActivity.this, MainActivity.class);
                        startActivity(intent);
                        timeDownCount.cancel();
                    }
                });
            }
        };
    }
}